package com.example.joke.custom.tag

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import com.example.joke.R
import com.example.joke.base.navigationbar.AbsNavigationBar
import com.example.joke.databinding.ActivityTagBinding
import com.example.joke.frame.BaseSkinActivity
import com.example.joke.frame.DefaultNavigationBar

class TagActivity : BaseSkinActivity<ActivityTagBinding>() {

    private val list = listOf("123", "微信", "支付宝", "12306", "北京一卡通", "节奏大师", "QQ", "微博", "小红书", "抖音", "QQ邮箱", "哔哩哔哩")
    override fun setListener() {
    }

    override fun initData() {
        binding.tag.mAdapter = object : BaseAdapter() {
            override fun getCount(): Int {
                return list.size
            }

            override fun getView(position: Int, parent: ViewGroup): View {
                val textView: TextView =
                    LayoutInflater.from(this@TagActivity).inflate(R.layout.item_tag, parent, false) as TextView
                textView.text = list[position]
                textView.setOnClickListener {
                    Toast.makeText(this@TagActivity, list[position], Toast.LENGTH_LONG).show()
                }
                return textView
            }

        }
    }

    override fun initTitle() {
        DefaultNavigationBar.Builder(this)
            .setTitle("TagLayout流式布局")
            .builder<AbsNavigationBar.Builder.AbsNavigationParams>()
    }

    override fun getBinding1(): ActivityTagBinding {
        return ActivityTagBinding.inflate(layoutInflater)
    }
}